package com.weetop.aklyscan.presenter;

import android.app.Activity;

import com.weetop.aklyscan.appConfig.MyApplication;
import com.weetop.aklyscan.base.mvp.BaseModel;
import com.weetop.aklyscan.base.mvp.BaseObserver;
import com.weetop.aklyscan.base.mvp.BasePresenter;
import com.weetop.aklyscan.bean.BaseList;
import com.weetop.aklyscan.bean.BaseObject;
import com.weetop.aklyscan.bean.FittingInfo;
import com.weetop.aklyscan.bean.InventoryOrderBean;
import com.weetop.aklyscan.bean.RecordBean;
import com.weetop.aklyscan.bean.RecordListBean;
import com.weetop.aklyscan.bean.SerailBean;
import com.weetop.aklyscan.view.InventoryView;

import org.json.JSONArray;

import java.util.List;

public class InventoryPresent extends BasePresenter<InventoryView> {
    public InventoryPresent(InventoryView baseView, Activity activity) {
        super(baseView, activity);
    }

    public void Into48(String order_sn) {
        addDisposable(apiServer.Into48(order_sn), new BaseObserver<BaseModel<InventoryOrderBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<InventoryOrderBean> o) {
                baseView.getInto48Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into66(String order_sn, String matter_code) {
        addDisposable(apiServer.Into66(order_sn, matter_code), new BaseObserver<BaseModel<SerailBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<SerailBean> o) {
                baseView.getInto66Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }



    public void Into13(String code) {
        addDisposable(apiServer.Into13(code), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                baseView.getInto13Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }
    public void Into63(String order_sn) {
        addDisposable(apiServer.Into63(order_sn), new BaseObserver<BaseModel<BaseObject<InventoryOrderBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseObject<InventoryOrderBean>> o) {
                baseView.getInto69Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into64(String type, String order_sn, String warehouse_coordinates,
                       String transit_code, String matter_code, String pd_num) {
        addDisposable(apiServer.Into64(type, order_sn, warehouse_coordinates, transit_code, matter_code, pd_num), new BaseObserver<BaseModel<Object>>(baseView) {
            @Override
            public void onSuccess(BaseModel<Object> o) {
                Into07(matter_code);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into69(String order_sn) {
        addDisposable(apiServer.Into69(order_sn), new BaseObserver<BaseModel<BaseObject<InventoryOrderBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseObject<InventoryOrderBean>> o) {
                baseView.getInto69Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onDataError();
                }
            }
        });
    }

    public void Into07(String matter_code) {
        addDisposable(apiServer.Into07(matter_code), new BaseObserver<BaseModel<FittingInfo>>(baseView) {
            @Override
            public void onSuccess(BaseModel<FittingInfo> o) {
                baseView.getInto07Success(matter_code, o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into49(String order_sn, String type, String items) {
        addDisposable(apiServer.Into49(order_sn, type, items), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto49Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void Into65(String order_sn, String type, JSONArray items) {
        addDisposable(apiServer.Into65(order_sn, type, items), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto49Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void Into71(String order_sn, String type, JSONArray items) {
        addDisposable(apiServer.Into71(order_sn, type, items), new BaseObserver<BaseModel<String>>(baseView) {
            @Override
            public void onSuccess(BaseModel<String> o) {
                baseView.getInto71Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.onUpFail(msg);
                }
            }
        });
    }

    public void serail(String code) {
        addDisposable(apiServer.serail("1", code, "1", MyApplication.getPort(), "0"),
                new BaseObserver<BaseModel<SerailBean>>(baseView) {
                    @Override
                    public void onSuccess(BaseModel<SerailBean> o) {
                        baseView.getserailSuccess(o);
                    }

                    @Override
                    public void onError(String msg) {
                        if (baseView != null) {
                            baseView.onUpFail(msg);
                        }
                    }
                });
    }

    public void Into50(String order_sn) {
        addDisposable(apiServer.Into50(order_sn), new BaseObserver<BaseModel<List<RecordListBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<RecordListBean>> o) {
                baseView.getInto50Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into73(String order_sn) {
        addDisposable(apiServer.Into73(order_sn), new BaseObserver<BaseModel<BaseList<RecordListBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseList<RecordListBean>> o) {
                baseView.getInto73Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void Into67(String order_sn) {
        addDisposable(apiServer.Into67(order_sn), new BaseObserver<BaseModel<BaseList<RecordListBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseList<RecordListBean>> o) {
                baseView.getInto73Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    public void Into51(String pd_time, String order_sn) {
        addDisposable(apiServer.Into51(pd_time, order_sn), new BaseObserver<BaseModel<List<RecordBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<List<RecordBean>> o) {
                baseView.getInto51Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }

    public void Into74(String pd_time, String order_sn) {
        addDisposable(apiServer.Into74(pd_time, order_sn), new BaseObserver<BaseModel<BaseList<RecordBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseList<RecordBean>> o) {
                baseView.getInto74Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }


    public void Into68(String pd_time, String order_sn) {
        addDisposable(apiServer.Into68(pd_time, order_sn), new BaseObserver<BaseModel<BaseList<RecordBean>>>(baseView) {
            @Override
            public void onSuccess(BaseModel<BaseList<RecordBean>> o) {
                baseView.getInto74Success(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
}
